package com.eastfair.home.controller;

import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.home.service.HomeServiceProviderService;
import com.eastfair.venueservice.dto.ServiceProviderDTO;
import com.eastfair.venueservice.vo.ServiceProviderVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 主场服务商信息
 * </p>
 *
 * @author lyw
 * @date 2022-07-15
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/homeServiceProvider")
@Api(value = "homeServiceProvider", tags = "主场服务商信息")
public class HomeServiceProviderController {

    @Autowired
    private HomeServiceProviderService homeServiceProviderService;

    /**
     * 查询主场服务商信息
     * @param userId
     * @return
     */
    @GetMapping("/getHomeServiceProviderByUserId/{userId}")
    public R<ServiceProviderVO> getHomeServiceProviderByUserId(@PathVariable Long userId) {
        ServiceProviderVO serviceProviderVO = homeServiceProviderService.getHomeServiceProviderByUserId(userId);
        return R.success(serviceProviderVO);
    }

    /**
     * 新增主场服务商信息
     * @return
     */
    @PostMapping("/saveHomeServiceProvider")
    public R<Boolean> saveHomeServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO){
      return R.success(homeServiceProviderService.saveHomeServiceProvider(serviceProviderDTO));

    }

    /**
     * 更新主场服务商信息
     * @return
     */
    @PostMapping("/updateHomeServiceProvider")
    public R<Boolean> updateHomeServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO){
        return R.success(homeServiceProviderService.updateHomeServiceProvider(serviceProviderDTO));
    }


}
